home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Leonardo the Inventor
/
Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso
/
LEOWINMV
/
DATABASE.DIR
/
00103_Script_INDEX INDEX
< prev
next >
Wrap
Text File
|
1996-03-28
|
5KB
|
134 lines
-- --------------------------------------------------------------
-- Handler setLeo2Index
on setLeo2Index
extractIndexIndex 332, 357
spreadIndexIndexToCasts 358, 360
end
-- --------------------------------------------------------------
-- Handler extractIndexIndex is given the numbers of the first
-- index cast and the last index cast and creates an index of the
-- index where entries of the indexIndex are of the form:
-- <indexEntry>:<indexCast>:<line in indexCast>
on extractIndexIndex firstCast, lastCast
global IndexIndex
set IndexIndex = ""
repeat with C = firstCast to lastCast
put "Extracting cast: " & the name of cast C -- LOG
set indexText = field C
repeat with L = 1 to the number of lines of indexText - 1
set aLine = line L of indexText
if (char 1 of aLine = "*") then
put (char 2 to 99 of aLine) & ":" & C & ":" & L & RETURN after IndexIndex
end if
end repeat
end repeat
put "Finished Extracting." -- LOG
end
-- --------------------------------------------------------------
-- Handler spreadIndexIndexToCasts divides the global variable
-- indexIndex (created in extractIndexIndex) into groups of
-- 1000 lines and stores these lines in cast members named
-- "IndexIndex1", "IndexIndex2" ...
on spreadIndexIndexToCasts firstCast, lastCast
global indexIndex
set numLines = the number of lines of IndexIndex
repeat with C = 1 to (lastCast + 1) - firstCast
put line ((C - 1) * 1000 ) + 1 to ((C - 1) * 1000 ) + 1000 of indexIndex into cast firstCast + C - 1
put RETURN after cast firstCast + C - 1
set the name of cast firstCast + C - 1 to "IndexIndex " & string(C)
end repeat
put "Finished Spreading. Casts: " & firstCast && "to" && lastCast -- LOG
end
-- --------------------------------------------------------------
-- Handler initIndexIndex initialized four global variables,
-- indexIndex1, ... indexIndex4 to the index of the index (stored
-- in fields "IndexIndex1", "IndexIndex2" ... "IndexIndex<n>").
on initIndexIndex
global IndexIndex1, IndexIndex2, IndexIndex3, IndexIndex4
set indexIndex1 = ""
set indexIndex2 = ""
set indexIndex3 = ""
set indexIndex4 = ""
repeat with C = 1 to 3
set pack = (the text of field ("indexIndex" && string(C))) & RETURN
set IndexIndex1 = IndexIndex1 & pack
set pack = ""
end repeat
-- repeat with C = 4 to 6
-- set pack = (the text of field ("indexIndex" && string(C))) & RETURN
-- set IndexIndex2 = IndexIndex2 & pack
-- set pack = ""
-- end repeat
--
-- repeat with C = 7 to 9
-- set pack = (the text of field ("indexIndex" && string(C))) & RETURN
-- set IndexIndex3 = IndexIndex3 & pack
-- set pack = ""
-- end repeat
--
-- repeat with C = 10 to 13
-- set pack = (the text of field ("indexIndex" && string(C))) & RETURN
-- set IndexIndex4 = IndexIndex4 & pack
-- set pack = ""
-- end repeat
end
-- --------------------------------------------------------------
-- Handler getIndexIndexData returns the index of the given word
-- using the index of the index.
on getIndexIndexData aWord
global IndexIndex1, IndexIndex2, IndexIndex3, IndexIndex4
set the itemDelimiter = ":"
-- quick search, get the indexIndex that contains the given
-- word by comparing it to the first word in the indices.
-- if (aWord < item 1 of IndexIndex2) then
-- set theIndexIndex = IndexIndex1
-- else if (aWord < item 1 of IndexIndex3) then
-- set theIndexIndex = IndexIndex2
-- else if (aWord < item 1 of IndexIndex4) then
-- set theIndexIndex = IndexIndex3
-- else
-- set theIndexIndex = IndexIndex4
-- end if
set theIndexIndex = IndexIndex1
-- now get the line in the indexIndex that contains the word
set theLine = binSearchFirstItemInLine (theIndexIndex, aWord, ":")
if (theLine = 0) then -- the word is not in the index
set the itemDelimiter = ","
return ""
end if
-- the word is in the index
set wordData = line theLine of theIndexIndex
set nextWordData = line theLine + 1 of theIndexIndex
set indexCast = item 2 of wordData
set indexCastLine1 = item 3 of wordData
set indexCastLine2 = item 3 of nextWordData
set the itemDelimiter = ","
return line value(indexCastLine1)+1 to value(indexCastLine2)-1 of field value(indexCast)
end